<template>
    <div>
        <h1>登录</h1>
        <table class="table">
            <thead>
                <tr>
                    <td>Username</td>
                    <td>
                        <input type="text" v-model="data.Username">
                    </td>
                </tr>
                <tr>
                    <td>Userpwd</td>
                    <td>
                        <input type="password" v-model="data.Userpwd">
                    </td>
                </tr>
                <tr>
                    
                    <td><input type="button" value="登录" class="btn btn-success" @click="dengl()"></td>
                </tr>
            </thead>
        </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref } from 'vue';

const data = ref({
Username:"",
Userpwd:""
})

const dengl = ()=>{
    axios.get("https://localhost:7292/api/User/Login",{params:data.value}).then(res=>{
        
        if(res.data==-1)
        {
            alert("名称不存在");
        }
        else if(res.data==-2)
        {
            alert("密码错误");
        }
        else if(res.data==3)
        {
            alert("登录成功");
            location.href="/ShowBF";
        }
        else
        {
            alert("登录失败");
        }
    })
}
</script>

<style scoped>

</style>